<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/page/base.jsp"%>
<%@ taglib prefix="d" uri="/doone-comm-ui-tags"%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
	    <base href="<%=basePath%>"></base>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title></title>
		<!-- Libraries -->
		<link type="text/css" href="<%=path %>/manage/css/layout.css" rel="stylesheet" />
		<link type="text/css" href="<%=path%>/manage/css/new_style.css" rel="stylesheet" />
		<script type="text/javascript" src="<%=path %>/manage/js/jquery-1.4.4.min.js"></script>
		<script type="text/javascript" src="<%=path %>/manage/js/easyTooltip.js"></script>
		<script type="text/javascript" src="<%=path %>/manage/js/jquery-ui-1.8.11.custom.min.js"></script>
		<script type="text/javascript" src="<%=path %>/manage/js/jquery.wysiwyg.js"></script>
		<script type="text/javascript" src="<%=path %>/manage/js/hoverIntent.js"></script>
		<script type="text/javascript" src="<%=path %>/manage/js/superfish.js"></script>
		<script type="text/javascript" src="<%=path %>/manage/js/custom.js"></script>
		<script type="text/javascript" src="<%=path %>/manage/js/My97DatePicker/WdatePicker.js"></script>
		<sx:head />
		<script language="javascript" type="text/javascript">
			function openOrder(intOrderId,type) {
			   $("#openOrderDialog").dialog("open");	
			   $("#oprOrderId").html(intOrderId);
			   $("#shipType").val("");
			   	$("#shipSn").val("");
			   if(type==0){
			   	$("#shipTypeLable").html("卡号");
			   	$("#shipSnLable").html("密码");
			   } else {
			   	$("#shipTypeLable").html("物流公司");
			   	$("#shipSnLable").html("物流单号");
			   }
			}
			$(document).ready(function() {
				//加载消息编辑dialog
				$("#openOrderDialog").dialog({
					autoOpen : false,
					width : 420,
					height :220,
					modal : true,
					title : '发货',
					buttons :{
						"保存" : function() {
							$.ajax({
								url : root+'/pns/doOrderSend.action',
								method : 'post',
								data:{'id' : $("#oprOrderId").html(),'shipType':encodeURI(encodeURI($("#shipType").val())),'shipSn':encodeURI(encodeURI($("#shipSn").val()))},
								success : function(data) {
								      $("#oprOrderInfo").html("提交成功");
								      setTimeout(function(){
								      	  deliveryChCallBack();
								      }, 1000);
								},
								error:function(err){
									if(err.responseText!='')
										alert(err.responseText);
									else
										alert("请求失败");
								}
							});
						},
						"取消" : function() {
							$(this).dialog("close");
						}
					},
					close : function() {
					}
		        
			});
			$( "#tabs" ).tabs();
			});
			
			function deliveryChCallBack() {
				$("#openOrderDialog").dialog("close");
		      	$("#oprOrderInfo").html("");
		      	var shipType = $("#deliveryComV"+$("#oprOrderId").html());
		      	var orderId = $("#oprOrderId").html();
		      	if($(shipType).length > 0){
		      		$("#deliveryComV"+orderId).html($("#shipType").val());
		      		$("#deliveryNumV"+orderId).html($("#shipSn").val());
		      	} else {
		      		var shipLink = $("#sendLink"+orderId);
		      		$(shipLink).before($("#shipTypeLable").html()+":<span id=\"deliveryComV"+orderId+"\">"+$("#shipType").val()+"</span><br>");
		      		$(shipLink).before($("#shipSnLable").html()+":<span id=\"deliveryNumV"+orderId+"\">"+$("#shipSn").val()+"</span><br>");
		      		$(shipLink).html("[修改]");
		      		$(shipLink).css("color","#F90");
		      		$("#shipStatus"+orderId).html("已发货");
		      	}
			}
		</script>

	</head>

	<body>
		
		<div >
			<p class="sitemap">当前位置：内容管理 > 订单管理</p>
            <h1>订单管理</h1>
		</div>
		<div id="tabs">
			<ul>
				<li><a href="#tabs-1">全部商品</a></li>
				
			</ul>
		</div>
		<div id="tabs-1">
			<div>
				<form name="searchForm" id="searchForm" method="post" action="<%=path %>/pns/getOrderInfo.action" style="margin:10px 0;">
					<s:textfield
						onfocus="if(this.value=='订单编号/收货人/手机号/物流单号'){this.value=''}"
						onblur="if(this.value==''){this.value='订单编号/收货人/手机号/物流单号'}"
						name="condition.keyWord" id="searchKeyWord" size="35" />
					<s:select list="productStatusList" name="condition.productIsReal"
								listKey="key" listValue="value" cssStyle="display:none"></s:select>
               		<s:select list="orderStatusList" name="condition.orderStatus"
								listKey="key" listValue="value"></s:select>
					<s:select list="payStatusList" name="condition.payStatus"
								listKey="key" listValue="value"></s:select>
					<s:select list="shipStatusList" name="condition.shipStatus"
								listKey="key" listValue="value"></s:select>
					<input type="submit" id="searchBtn" value="检索" >
				</form> 
			</div>
			<style>
				#productTable td{border:1px solid #e6e6e6}
			</style>
            <table cellspacing="0" style="border-collapse:collapse;line-height:18px;" cellpadding="0" border="0" class="fullwidth" id="productTable">
                <thead>
                   <tr>
                     <th width="30%" height="30px">商品</th>
                     <th width="5%">单价</th>
                     <th width="5%">数量</th>
                     <th width="5%">总额</th>
                      <th width="10%">订单状态</th>
                      <th width="10%">支付方式</th>
                     <th width="20%">收货人信息</th>
                     <th width="20%">物流信息</th>
                   </tr>
                   <tr>
                   	<td height="5" colspan="8" bgcolor="white" style="border-right-color:white;border-left-color:white;"></td>
                   </tr>
                 </thead>
                 <s:iterator value="orderDto" status="st">
                 	<tbody>
	                   <tr>
	                   	<td colspan="8" bgcolor="#f3f3f3">
	                   		订单编号：<s:property value="ecOrders.orderSn"/>
	                   		&nbsp;&nbsp;&nbsp;&nbsp;
	                   		成交时间：<s:property value="ecOrders.createDt"/>
	                   	</td>
	                   </tr>
	                   <s:iterator value="ecOrderDetailsDto" status="details">
	                   		<tr>
			                   	<td style="border-left-color:white;" valign="top">
			                   		<s:if test="ecProduct.isReal==0">
			                   			<img src="<%=path %>/manage/images/icon_xu.jpg" width="19px" height="19px" style="vertical-align:top;margin-right:3px;"/><s:property value="ecOrderDetails.productName"/>
			                   		</s:if>
			                   		<s:else>
			                   			<img src="<%=path %>/manage/images/icon_shi.jpg" width="19px" height="19px" style="vertical-align:top;margin-right:3px;"/><s:property value="ecOrderDetails.productName"/>
			                   		</s:else>
			                   	</td>
			                   	<td align="center" valign="top">
			                   		<s:property value="ecOrderDetails.price"/>
			                   	</td>
			                   	<td align="center" valign="top" >
			                   		<s:property value="ecOrderDetails.quantity"/>
			                   	</td>
			                   	<s:if test="#details.first">
			                   		<td align="center" rowspan="<s:property value='ecOrderDetailsDto.size()'/>" valign="top">
				                   		<s:property value="ecOrders.totalPrice"/>
				                   	</td>
				                   	<td align="center" rowspan="<s:property value='ecOrderDetailsDto.size()'/>" valign="top">
				                   		<s:if test="ecOrders.orderStatus==5">
				                   			交易成功
				                   		</s:if>
				                   		<s:else>
				                   			<span>
				                   				<s:if test="ecOrders.orderStatus==0">未确认</s:if>
						                   		<s:elseif test="ecOrders.orderStatus==1">已确认</s:elseif>
						                   		<s:elseif test="ecOrders.orderStatus==2">已取消</s:elseif>
						                   		<s:elseif test="ecOrders.orderStatus==3">无效</s:elseif>
						                   		<s:elseif test="ecOrders.orderStatus==4">退货</s:elseif>
				                   			</span>
				                   			<br/>
				                   			<span>
				                   				<s:if test="ecOrders.payStatus==0">未付款</s:if>
						                   		<s:elseif test="ecOrders.payStatus==1">付款中</s:elseif>
						                   		<s:elseif test="ecOrders.payStatus==2">已付款</s:elseif>
				                   			</span>
					                   		<br/>
					                   		<span id="shipStatus<s:property value='ecOrders.id' />">
					                   			<s:if test="ecOrders.shipStatus==0">未发货</s:if>
						                   		<s:elseif test="ecOrders.shipStatus==1">配货中</s:elseif>
						                   		<s:elseif test="ecOrders.shipStatus==2">已发货</s:elseif>
						                   		<s:elseif test="ecOrders.shipStatus==3">已收货</s:elseif>
					                   		</span>
				                   		</s:else>
				                   	</td>
				                   	<td align="center" rowspan="<s:property value='ecOrderDetailsDto.size()'/>" valign="top">
				                   		<s:if test="ecOrders.paymentType==1">在线支付</s:if>
				                   		<s:elseif test="ecOrders.paymentType==2">货到付款</s:elseif>
				                   		<s:elseif test="ecOrders.paymentType==3">在线支付/货到付款</s:elseif>
				                   		<s:elseif test="ecOrders.paymentType==9">积分支付</s:elseif>
				                   	</td>
				                   	<td align="left" rowspan="<s:property value='ecOrderDetailsDto.size()'/>" valign="top">
				                   		<s:property value="ecOrders.title" />，<s:property value="ecOrders.phoneNumber" /><br>
				                   		<s:property value="ecOrders.addressLine" /><br>
				                   		备注：<s:property value="ecOrders.note" />
				                   	</td>
				                   	<td rowspan="<s:property value='ecOrderDetailsDto.size()'/>" style="border-right-color:white;" valign="top">
				                   		<s:if test="ecOrders.orderStatus==1 && ecOrders.shipStatus==0">
				                   			<s:if test="ecOrders.paymentType==2">
					                   			<a id="sendLink<s:property value='ecOrders.id' />" href="javascript:openOrder('<s:property value="ecOrders.id" />','<s:property value="ecProduct.isReal" />')" style="color:#693">[发货]</a>
					                   		</s:if>
					                   		<s:else>
					                   			<s:if test="ecOrders.payStatus==2">
						                   			<a id="sendLink<s:property value='ecOrders.id' />" href="javascript:openOrder('<s:property value="ecOrders.id" />','<s:property value="ecProduct.isReal" />')" style="color:#693">[发货]</a>
						                   		</s:if>
					                   		</s:else>
				                   		</s:if>
				                   		<s:elseif test="ecOrders.shipStatus==2">
				                   			<s:if test="ecProduct.isReal==0">
				                   				卡号:<span id="deliveryComV<s:property value='ecOrders.id' />"><s:property value="ecOrders.shipType" /></span><br>
				                   				密码:<span id="deliveryNumV<s:property value='ecOrders.id' />"><s:property value="ecOrders.shipSn" /></span><br>
				                   				<s:if test="ecOrders.orderStatus!=5">
				                   					<a href="javascript:openOrder('<s:property value="ecOrders.id" />','<s:property value="ecProduct.isReal" />')" style="color:#F90">[修改]</a>
				                   				</s:if>
				                   			</s:if>
				                   			<s:else>
				                   				物流公司:<span id="deliveryComV<s:property value='ecOrders.id' />"><s:property value="ecOrders.shipType" /></span><br>
				                   				物流单号:<span id="deliveryNumV<s:property value='ecOrders.id' />"><s:property value="ecOrders.shipSn" /></span><br>
				                   				<s:if test="ecOrders.orderStatus!=5">
				                   					<a href="javascript:openOrder('<s:property value="ecOrders.id" />','<s:property value="ecProduct.isReal" />')" style="color:#F90">[修改]</a>
				                   				</s:if>
				                   			</s:else>
				                   		</s:elseif>
				                   	</td>
			                   	</s:if>
		                   </tr>
	                   </s:iterator>
	                 </tbody>
                 </s:iterator>
             </table>
			<!-- 分页标签开始 -->
              <div align="right" style="float:right;">
               <d:page id="page" template="details" skin="gray">
               </d:page>
              </div>
               <!-- 分页标签结束 -->
				<hr />
		</div>
		<div id="openOrderDialog" style="display: none;">
			<table class="fullwidth" cellpadding="0" cellspacing="0"
				border="0">
				<tr>
					<td id="shipTypeLable">
						物流公司
					</td>
					<td>									   
						<input type="text" id="shipType">
					</td>
				</tr>
				<tr>
					<td id="shipSnLable">
						物流单号
					</td>
					<td>									   
						<input type="text" id="shipSn">
					</td>
				</tr>
			</table>
			<div id="oprOrderId" style="display:none"></div>
			<div id="oprOrderInfo"></div>
		</div>
	</body>
</html>
